<template>
  <div id="OrdersTitle">
    <v-details :inputConfig="inputConfig"
               :detailData="inputData"
               :rules="rules"
               @pop="setdata"
               ref="input"></v-details>
  </div>
</template>

<script>
import details from 'commons/Detail'
import baseMixin from "@/mixins/BaseMixin";

export default {
  props: {
    inputData: {
      type: Object,
    }
  },
  mixins: [baseMixin],
  name: "OrdersTitle",
  data () {
    return {
      newFlag: false,
    }
  },
  computed: {
    inputConfig () {
      if (this.newFlag) {
        return [
          [
            {
              type: "table",
              label: this.$t('work.totalkey'),
              props: "totalkey",
              tableConfig: [
                {
                  label: this.$t('config.shipper'),
                  prop: "storerkey",
                  input: "input",
                },
                {
                  label: this.$t('work.totalkey'),
                  prop: "totalkey",
                  input: "input",
                },
                {
                  label: this.$t('common.date'),
                  prop: "adddate",
                  input: "date",
                },
                {
                  label: this.$t('common.status'),
                  prop: "status",
                  input: "select",
                  options: this.getOptions("querycodeLkup/LADYCCSTATUS")
                },
                {
                  label: this.$t('security.desc'),
                  prop: "notes",
                  input: "input",
                },
              ],
              url: `/queryRtx_ccparenttaskList/`
            },
            {
              type: "input",
              label: this.$t('work.fromarea'),
              props: "fromarea",
            },
            {
              type: "input",
              label: this.$t('work.fromzone'),
              props: "fromzone",
            },
            {
              type: "date",
              label: this.$t('work.updatefrom'),
              props: "updatefrom",
            },
            {
              type: "select",
              label: this.$t('common.type'),
              props: "cctype",
              options: this.getOptions("querycodeLkup/LADYCCTYPE")
            }
          ],
          [
            {
              type: "input",
              label: this.$t('work.subkey'),
              props: "subkey",
              disabled: true,
            },
            {
              type: "input",
              label: this.$t('work.toarea'),
              props: "toarea",
            },
            {
              type: "input",
              label: this.$t('work.tozone'),
              props: "tozone",
            },
            {
              type: "date",
              label: this.$t('work.updateto'),
              props: "updateto",
            },
            {
              type: "checkbox",
              label: this.$t('work.isblind'),
              props: "isblind",
            },
            {
              type: "checkbox",
              label: this.$t('work.dynamic'),
              props: "dynamic",
            },
          ]
        ]
      } else {
        return [
          [
            {
              type: "input",
              label: this.$t('work.totalkey'),
              disabled: true,
              props: "totalkey",
            },
            {
              type: "input",
              label: this.$t('work.subkey'),
              disabled: true,
              props: "subkey",
            },
            {
              type: "select",
              label: this.$t('common.type'),
              props: "type",
              options: this.getOptions("querycodeLkup/LADYCCTYPE")
            },
          ],
        ]
      }
    },
    rules () {
      if (this.newFlag) {
        return {
          totalkey: [
            { required: true, trigger: 'blur' },
          ],
          fromarea: [
            { required: true, trigger: 'blur' },
          ],
          fromzone: [
            { required: true, trigger: 'blur' },
          ],
          cctype: [
            { required: true, trigger: 'blur' },
          ],
          subkey: [
            { required: true, trigger: 'blur' },
          ],
          toarea: [
            { required: true, trigger: 'blur' },
          ],
          tozone: [
            { required: true, trigger: 'blur' },
          ],
        }
      } else {
        return {
          totalkey: [
            { required: true, trigger: 'blur' },
          ],
          subkey: [
            { required: true, trigger: 'blur' },
          ],
          type: [
            { required: true, trigger: 'blur' },
          ]
        }
      }
    }
  },
  methods: {
    setdata (data, id, close, listId) {
      this.inputData.totalkey = data.totalkey;
      close(false);
    }
  },
  mounted () {
    if (Object.keys(this.$store.state.skip).length !== 0) {
      let data = this.$store.state.skip;
      this.newFlag = data.newFlag;
    } else {
      this.newFlag = this.$store.state.newFlag;
    }
  },
  watch: {},
  components: {
    'v-details': details
  }
}
</script>

<style scoped>
</style>
